import React, { useState, useRef, useEffect } from 'react'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table'
import { connect, Link } from 'umi'
import { queryMonitorList} from '../service'
import {jobLevelTypeList} from "@/utils/constant";
import { formatNumber } from '@/utils/utils'

const TableList = ({global}) => {
  const { options = {} } = global
  const { orgLine = [], orgSystem = []} = options
  const actionRef = useRef()
  const columns = [
    {
      title: '体系',
      dataIndex: 'jobSystem',
      key:'jobSystem',
      render: (text) => {
        const res = orgSystem.find((item) => item.id === text)
        return res ? res.name : text
      }
    },
    {
      title: '条线',
      dataIndex: 'line',
      key:'line',
      render: (text) => {
        const res = orgLine.find((item) => item.id === text)
        return res ? res.name : text
      }
    },
    {
      title: '岗位',
      dataIndex: 'jobname',
      key:'jobname',
    },
    {
      title: '职级',
      dataIndex: 'jobLevel',
      key:'jobLevel',
    },
    {
      title: '工号',
      dataIndex: 'code',
      key:'code',
    },
    {
      title: '姓名',
      dataIndex: 'name',
      key:'name',
      width:60,
      render: (item, record) => (
        <Link to={`/info/details/${record.oid}`}>{item}</Link>
      ),
    },
    {
      title: '公司',
      dataIndex: 'orgname',
      key:'orgname',
    },
    {
      title: '部门',
      dataIndex: 'unitname',
      key:'unitname',
    },
    {
      title: '职级类型',
      dataIndex: 'jobLevelType',
      key:'jobLevelType',
      hideInSearch: true,
      render: (text) => {
        const res = jobLevelTypeList.find((item) => item.value === text)
        return res ? res.label : text
      }
    },
    {
      title: '带宽薪资标准上限',
      dataIndex: 'bandSalaryimit',
      key:'bandSalaryimit',
      hideInSearch: true,
      render:(text) =>{
        return formatNumber(text)
      },
    },
    {
      title: '申请薪资标准',
      dataIndex: 'monthlySalary',
      key:'monthlySalary',
      hideInSearch: true,
      render:(text) =>{
        return formatNumber(text)
      },
    },
    {
      title: '定薪涨薪',
      dataIndex: 'differenceSalary',
      key:'differenceSalary',
      hideInSearch: true,
      render:(text) =>{
        return formatNumber(text)
      },
    },
    // {
    //   title: '薪酬状态',
    //   dataIndex: 'status',
    //   key:'status',
    //   hideInSearch: true,
    //   render:(text) =>{
    //     return formatNumber(text)
    //   },
    // }
  ]

  return (
    <PageHeaderWrapper>
        <ProTable
          actionRef={actionRef}
          rowKey="oid"
          request={(params) => queryMonitorList(params)}
          columns={columns}
        />
    </PageHeaderWrapper>
  )
}

export default connect(({ global }) => ({
  global
}))(TableList)
